package org.gwh.airagknowledge.config;

import jakarta.persistence.Converter;
import org.springframework.context.annotation.Configuration;

/**
 * 配置PostgreSQL方言和pgvector相关功能
 */
@Configuration
public class PostgreSQLDialectConfig {
    
    /**
     * 转换器，用于将byte[]转换为PostgreSQL的vector类型
     * 在PostgreSQL驱动层处理转换
     */
    @Converter(autoApply = true)
    public static class ByteArrayToVectorConverter implements jakarta.persistence.AttributeConverter<byte[], byte[]> {
        
        @Override
        public byte[] convertToDatabaseColumn(byte[] attribute) {
            return attribute;
        }
        
        @Override
        public byte[] convertToEntityAttribute(byte[] dbData) {
            return dbData;
        }
    }
} 